
# this can be any application server, not just Unicorn/Rainbows!
upstream <%= fetch(:application) %>_server {
  server 0.0.0.0:3000;
  server 0.0.0.0:3001;
  # server unix:<%= shared_path %>/tmp/sockets/thin.0.sock fail_timeout=0;
  #  server unix:<%= shared_path %>/tmp/sockets/thin.1.sock fail_timeout=0;
}


server {
  # enable one of the following if you're on Linux or FreeBSD
  listen 80; # for Linux

  client_max_body_size 4G;
  server_name <%= fetch(:server_domain_name) %>;

  access_log <%= shared_path %>/log/nginx_access.log;
  error_log <%= shared_path %>/log/nginx_error.log error;

  keepalive_timeout 5;

  # path for static files
  root <%= current_path %>/public;



  try_files $uri/index.html $uri.html $uri @app;

  location @app {


    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto http;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_redirect off;
    proxy_pass http://<%= fetch(:application) %>_server;
  }
  error_page 500 502 503 504 /500.html;
    location = /500.html {
    root <%= current_path %>/public;
  }
}


